#ifndef CPU_H
#define CPU_H

#include <QObject>

class OperationFactory;
class Memory;

class CPU : public QObject
{
    Q_OBJECT

public:
    static const int T_REGISTERS = 34;
    static const int G_REGISTERS = 32;
    static const int ID_IR = 32;
    static const int ID_PC = 33;

public:
    virtual ~CPU();
    //
    void setRegisters(int index, const QString& content);
    QString getRegister(int index) const;
    void setPC(quint32 pc);
    quint32 getPC() const;
    void setIR(const QString& value);
    QString getIR() const;
    //
    void exec();

public:
    static CPU* getInstance(QObject* parent = 0);

private:
    CPU(QObject* parent = 0);
    static CPU* instance;

private:
    Memory* memory;
    OperationFactory* opFactory;
    quint32 PC;
    QString IR;
    QString registers[G_REGISTERS];

signals:
    void registersChanged(int id); //is emited when the contents of the registers are changed.
};

#endif // CPU_H
